package demoMod.nanaki.cards.nanaki;

import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.actions.common.DrawCardAction;
import com.megacrit.cardcrawl.actions.utility.ScryAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.powers.*;
import demoMod.nanaki.NanakiMod;

public class VientianeSphere extends AbstractNanakiCard {
    public static final String ID = NanakiMod.makeID("VientianeSphere");

    private static final CardStrings cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    public static final String NAME = cardStrings.NAME;
    public static final String DESCRIPTION = cardStrings.DESCRIPTION;
    public static final String IMG_PATH = "cards/VientianeSphere";

    private static final CardType TYPE = CardType.SKILL;
    private static final CardRarity RARITY = CardRarity.UNCOMMON;
    private static final CardTarget TARGET = CardTarget.SELF;

    private static final int COST = 1;

    public VientianeSphere() {
        super(ID, NAME, NanakiMod.getResourcePath(IMG_PATH), COST, DESCRIPTION, TYPE, RARITY, TARGET);
        this.exhaust = true;
    }

    @Override
    public Runnable getUpgradeAction() {
        return () -> {
            this.rawDescription = cardStrings.UPGRADE_DESCRIPTION;
            this.initializeDescription();
        };
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        addToBot(new ScryAction(1));
        if (p.drawPile.isEmpty()) {
            return;
        }
        AbstractCard topCard = p.drawPile.getTopCard();
        switch (topCard.type) {
            case ATTACK:
                addToBot(new ApplyPowerAction(p, p, new StrengthPower(p, upgraded ? 3 : 2)));
                break;
            case SKILL:
                addToBot(new ApplyPowerAction(p, p, new MetallicizePower(p, upgraded ? 3 : 2)));
                break;
            case POWER:
                addToBot(new DrawCardAction(upgraded ? 3 : 2));
                break;
            case STATUS:
                addToBot(new ApplyPowerAction(p, p, new BlurPower(p, upgraded ? 2 : 1)));
                break;
            case CURSE:
                addToBot(new ApplyPowerAction(p, p, new ArtifactPower(p, upgraded ? 2 : 1)));
                break;
        }
    }
}
